package tessk.controller;


import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.plugins.Page;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import tessk.entity.User;
import tessk.service.IUserService;

/**
 * 
 * 代码生成器，参考源码测试用例：
 * 
 * /mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/generator/MysqlGenerator.java
 *
 */
@RestController
@RequestMapping("/user")
@Api(value = "/user", description = "Operations about user")
public class UserController {

	@Autowired
	private IUserService userService;

	/**
	 * 分页 PAGE
	 */
	@GetMapping("/test")
	public Page<User> test() {
		return userService.selectPage(new Page<User>(0, 12));
	}

	@ApiOperation(value="获取用户列表", notes="根据User对象创建用户")
	@GetMapping("/getall")
	public List<User> test1() {
		User user = new User();
		user.setUserId("123456");
		user.setName("贴狂顶狂顶");
		List<User> list = new ArrayList<User>();
		list.add(user);
		return list;

	}
	
	@ApiOperation(value="获取用户详细信息", notes="根据url的id来获取用户详细信息")
	@ApiParam(name = "id", value = "用户ID", required = true)
	@GetMapping("/infobyid")
	public User test2(@RequestParam String id){
		User ss =userService.queryInfoById(id);
		return ss;
	}

}
